/**
 * @brief spi nor flash驱动
 * @version V1.0
*/

#include "debug.h"
#include "string.h"

/* Winbond SPIFalsh ID */
#define W25Q80                   0XEF13
#define W25Q16                   0XEF14
#define W25Q32                   0XEF15
#define W25Q64                   0XEF16
#define W25Q128                  0XEF17

/* Winbond SPIFalsh Instruction List */
#define W25X_WriteEnable         0x06
#define W25X_WriteDisable        0x04
#define W25X_ReadStatusReg       0x05
#define W25X_WriteStatusReg      0x01
#define W25X_ReadData            0x03
#define W25X_FastReadData        0x0B
#define W25X_FastReadDual        0x3B
#define W25X_PageProgram         0x02
#define W25X_BlockErase          0xD8
#define W25X_SectorErase         0x20
#define W25X_ChipErase           0xC7
#define W25X_PowerDown           0xB9
#define W25X_ReleasePowerDown    0xAB
#define W25X_DeviceID            0xAB
#define W25X_ManufactDeviceID    0x90
#define W25X_JedecDeviceID       0x9F



#define  DUMMY_BYTE                    0xFF
#define  SPI_FLASH_CS_LOW()            GPIO_WriteBit(GPIOA, GPIO_Pin_2, 0);
#define  SPI_FLASH_CS_HIGH()           GPIO_WriteBit(GPIOA, GPIO_Pin_2, 1);

extern void SPI_Flash_Init(void);
extern u16 SPI_Flash_ReadID(void);